home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / kant-generator-04-c / Kant ƒ / Shell ƒ / file interface.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  1.2 KB  |  41 lines  |  [TEXT/MMCC]

  1. #include "file interface.h"
  2. #include "program globals.h"
  3.  
  4. Boolean GetSourceFile(FSSpec *sourceFS)
  5. /* a standard procedure which shows an open dialog box and returns the FSSpec of
  6.    the file you selected (or returns FALSE if you cancelled) */
  7. {
  8.     StandardFileReply    reply;
  9.     SFTypeList            theTypes;
  10.     
  11.     theTypes[0]=SAVE_TYPE;
  12.     theTypes[1]='????';
  13.     StandardGetFile(0L, 2, theTypes, &reply);    /* reply's got an FSSpec in it afterwards */
  14.  
  15.     if (reply.sfGood)
  16.         FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name,
  17.                             sourceFS);
  18.         
  19.     return reply.sfGood;    /* TRUE if we have a valid file selected */
  20. }
  21.  
  22. Boolean GetDestFile(FSSpec *destFS, Boolean *deleteTheThing, Str255 theTitle)
  23. /* a standard save dialog box -- given a title (for the prompt), it returns the
  24.    file's FSSpec in destFS and whether a file of that name already exists in
  25.    deleteTheThing (TRUE if file already exists) */
  26. /* details are pretty much the same as GetSourceFile(), see above */
  27. {
  28.     StandardFileReply    reply;
  29.         
  30.     StandardPutFile(theTitle, destFS->name, &reply);
  31.  
  32.     if (reply.sfGood)
  33.     {
  34.         *deleteTheThing=reply.sfReplacing;    
  35.         FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name,
  36.                         destFS);
  37.     }
  38.     
  39.     return reply.sfGood;
  40. }
  41.